// 引用mongoose
const mongoose = require('mongoose')

// 连接MongoDB数据库
mongoose
  .connect('mongodb://127.0.0.1:27017/myapp', {
    // useNewUrlParser: true,
    // useUnifiedTopology: true,
  })
  .then(() => console.log('Connected to MongoDB'))
  .catch((err) => console.log('Failed to connect to MongoDB', err))

// 导出mongoose对象
module.exports = mongoose
